package cookie;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/CookieDemo02")
public class CookieDemo02 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      //接收CookieDemo01中的Cookie对象
        //3:获取Cookie
        Cookie[] aa = req.getCookies();
        //获取数据,遍历Cookie
        if (aa != null){
            for (Cookie bb : aa){
                String cc = bb.getName();
                String dd = bb.getValue();
                System.out.println(cc+":"+dd);
            }
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
